<?php
namespace frontend\controllers;

use common\jobs\NewUserJob;
use common\services\ToolService;
use Yii;
use yii\web\Controller;
use common\models\LoginForm;
use Qcloud\Sms\SmsSingleSender;


/**
 * Site controller
 */
class PublicController extends Controller
{
    /**
     * @var string
     */
    public $layout = 'prim';

    /**
     * Displays homepage.
     *
     * @return mixed
     * @throws
     */
    public function actionIndex()
    {
        Yii::$app->response->data = 'hello index';
        Yii::$app->end();
    }

    /**
     * @return string|\yii\web\Response
     */
    public function actionLogin()
    {
        if (!Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        } else {
            $model->password = '';

            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }

    public function actionRegister()
    {
        return $this->render('register', [

        ]);
    }

    /**
     * @return string|\yii\web\Response
     * 登录页面
     */
    public function actionLoginvercode()
    {
        return $this->domainRender('loginvercode');
    }

    public function actionPrivacy()
    {
        return $this->render('privacy', [

        ]);
    }

    public function actionTest()
    {
//        $ud = new NewUserJob();
//        $ud->uid = 8 ;
//        $ud->initDefaultCategory();
//        echo time();
//        ToolService::sendInviteSms('13663002790',['name'=>'常子明']);
    }




}
